﻿// <copyright file="SetRadioSensitivity.cs" company="Hallvard Korsgaard">
//  Microsoft Public License (Ms-PL). See license details here: http://enoceannet.codeplex.com/license
// </copyright>
// <author>Hallvard Korsgaard</author> 

namespace EnOcean.Command
{
  using System;

  /// <summary>
  /// This command is used to set the TCM radio sensitivity. In Low radio sensitivity, signals from remote transmitters are 
  /// not detected by the TCM receiver. This feature is useful when only information from transmitters in the vicinity should be 
  /// processed. An Ok confirmation telegram is generated after TCM sensitivity has been changed. 
  /// </summary>
  [Serializable]
  public class SetRadioSensitivity : CommandTelegram
  {
    /// <summary>
    /// Initializes a new instance of the SetRadioSensitivity class. The radio sensitivity is set to high.
    /// </summary>
    public SetRadioSensitivity()
      : this(RadioSensitivity.High)
    {
    }

    /// <summary>
    ///  Initializes a new instance of the SetRadioSensitivity class.
    /// </summary>
    /// <param name="sensitivity">The RadioSensitivity.</param>
    public SetRadioSensitivity(RadioSensitivity sensitivity)
    {
      this.Sensitivity = sensitivity;
    }

    /// <summary>
    /// Gets or sets the radio sensitivity.
    /// </summary>
    public RadioSensitivity Sensitivity
    {
      get;
      set;
    }

    /// <summary>
    /// Creates the byte format of the message.
    /// </summary>
    /// <param name="message">A byte array of length 14 to hold the message contents.</param>
    protected internal override void CreateMessage(byte[] message)
    {
      base.CreateMessage(message);
      message[3] = (byte)CommandType.SetRadioSensitivity;
      message[4] = (byte)this.Sensitivity;
    }
  }
}
